package com.mysterlee.test;

import java.awt.Frame;
import java.awt.image.BufferedImage;
import java.awt.image.ImageObserver;
import java.io.File;
import javax.imageio.ImageIO;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.HttpVersion;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.mime.HttpMultipartMode;
import org.apache.http.entity.mime.MultipartEntity;
import org.apache.http.entity.mime.content.ContentBody;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.entity.mime.content.StringBody;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.CoreProtocolPNames;
import org.apache.http.util.EntityUtils;
import org.hsqldb.persist.Log;

public class HttpGetPostMutipartEntity extends Frame{	
	public static void main(String arg[]){
		File file = new File("path/to/your/file.txt");
		try
		{
		  HttpClient client = new DefaultHttpClient();
		  String postURL = "http://www.google.com";
		  HttpPost post = new HttpPost(postURL);
		  FileBody bin = new FileBody(file);
		  MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
		  reqEntity.addPart("myFile", bin);
		  post.setEntity(reqEntity);
		 
		  HttpResponse response = client.execute(post);
		  HttpEntity resEntity = response.getEntity();
		 
		  if (resEntity != null)
		  {    
		    //Log.i("RESPONSE", EntityUtils.toString(resEntity));
		  }
		}
		catch (Exception e)
		{
		  e.printStackTrace();
		}
	}
}